#!/usr/bin/env bash

if [ $# == 0 ]; then
    containers=`docker ps -a --format "table {{.Names}}" | grep -v 'NAMES'`

    for ctn in ${containers[@]}
    do
        ip=`docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $ctn`
        echo -e $ip"\t"$ctn
    done
else
    docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $1
fi
